<template>
  <div>
    <el-row>
      <el-col :xs="20" :sm="20" :md="12" :lg="6" :xl="6">
        <div>
          <el-form label-width="100px">
            <el-form-item label="用户名">
              <el-input v-model="form.username" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="密码" prop="pass">
              <el-input
                type="password"
                v-model="form.password"
                autocomplete="off"
              ></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="onSubmit">提交</el-button>
              <el-button @click="reset">重置</el-button>
            </el-form-item>
          </el-form>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import axios from "axios";

export default {
  data() {
    return {
      form: {
        username: "",
        password: "",
      },
    };
  },
  methods: {
    onSubmit() {
      console.log("submit!");
       axios
        .get(`http://localhost/loginAjax.php?username=${this.form.username}&password=${this.form.password}`)
        .then((response) => {
          console.log(response);
          this.$message.error(response.data.message);
        })
        .catch((error) => {
          console.error("There was an error!", error);
        });
    },
    reset() {
      this.form.username = "";
      this.form.password = "";
    },
  },
};
</script>
<style scoped>
.el-row {
  display: flex;
  justify-content: center;
  margin-top: 300px;
  margin-left: 50px;
  margin-right: 50px;
  background-color: aliceblue;
  padding: 50px;
}
.el-col {
}
</style>